<!-- 用户账户信息 -->
<template>
    <div>
        <div class="table-page-search-wrapper">
            <a-form :label-col="{ span: 6 }" :wrapper-col="{ span: 17 }">
                <a-form-item label="手机号">
                    <a-input v-model="phone" disabled allow-clear placeholder="暂无信息" />
                </a-form-item>
                <a-form-item label="姓名">
                    <a-input v-model="userName" disabled allow-clear placeholder="暂无信息" />
                </a-form-item>
                <a-form-item label="钱包地址">
                    <a-input v-model="address" disabled allow-clear placeholder="暂无地址">
                        <a-button slot="addonAfter" type="primary" @click="copy">
                            复制
                        </a-button>
                    </a-input>
                </a-form-item>
            </a-form>
        </div>
    </div>
</template>

<script>
// import { queryUserFilecoinAddress } from '@/api/member';
export default {
    props: {
        brandId: {},
        phone: {},
    },
    data () {
        return {
            userId: '',
            address: '',
            userName: '',
        };
    },
    watch:{
        phone: function(val,old){
            this.getData()
        },
    },
    created(){
        this.getData()
    },
    methods: {
        getData(){
            let _this = this
            const params = {
                'brandId':_this.brandId,
                'phone':_this.phone,
                'size':10,
                'page':0,
            }
            queryUserFilecoinAddress(params)
            .then(res=>{
                _this.isload = false
                if(res.success){
                    if(res.data.content.length > 0){
                        _this.userName = res.data.content[0].userName
                        _this.address = res.data.content[0].address
                    }else{
                        _this.userName = ''
                        _this.address = ''
                    }
                }else{
                    _this.$notification['error']({
                        message: '提示',
                        description: res.errMessage,
                        duration: 8,
                    })
                }
            })
        },
        copy(){
            console.log('复制')
            if(this.address == ''){
                this.$message.warning('暂无钱包地址信息')
                return
            }
            let target = document.createElement('div');
            target.id = 'tempTarget';
            target.style.opacity = '0';
            target.innerText = this.address;
            document.body.appendChild(target);
            let range = document.createRange();
            range.selectNode(target);
            window.getSelection().removeAllRanges();
            window.getSelection().addRange(range);
            document.execCommand('copy');
            window.getSelection().removeAllRanges();
            this.$message.success('复制成功')
        },
    }
}

</script>
<style scoped>

</style>